home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW Related / MPW Script Tips 1.1.1 / Sample Scripts / RenameProjFile < prev    next >
Encoding:
Text File  |  1991-08-16  |  2.5 KB  |  69 lines  |  [TEXT/MPS ]

  1. #----------------------------------------------------------------------------------------------------------------------------------------------------
  2. #    RenameProjectorFile
  3. #    MPW Shell Script
  4. #    Written by Gina Cherry • August 16, 1991
  5. #    Copyright:    © 1991 by Apple Computer, Inc., all rights reserved.
  6. #    
  7. #    WARNING:
  8. #        This script was written to demonstrate some of the features of the MPW command language, and
  9. #        is not recommended for actual use.  All previous versions of the Projector file will be lost 
  10. #        when the file is renamed.  To rename Projector files, use the script ChangeFileName found in 
  11. #        MPW Goodies.
  12. #        
  13. #    Usage:
  14. #        RenameProjectorFile oldName newName
  15. #        
  16. #    Function:
  17. #        RenameProjectorFile renames the specified Projector file.
  18. #        
  19. #    Note:
  20. #        RenameProjectorFile will always display an Alert warning the user that the old file is
  21. #        not in the current checkout directory.
  22. #----------------------------------------------------------------------------------------------------------------------------------------------------
  23.     
  24.     
  25. #    If the number of parameters is not equal to 2, write error message and exit script.
  26.     If {#} != 2
  27.         Echo "### Usage: {0} oldName newName"
  28.         Exit 1
  29.     End >> Dev:StdErr
  30.  
  31. #    Don't exit on error.    
  32.     Set Exit 0
  33.  
  34. #    Set variables to specified files.    
  35.     Set oldName "{1}"
  36.     Set newName "{2}"
  37.  
  38. #    Check out a write-priveleged copy of the file to be renamed.  If the CheckOut command is
  39. #    not successful, exit the script.
  40.     CheckOut -m "{oldName}" || Exit 2
  41.  
  42. #    Set info variable to the information returned by the ProjectInfo command.    
  43.     Set info "`ProjectInfo -comments "{oldName}"`"
  44.  
  45. # Parse this information to extract the revision number, the task, and the comment.  Create 
  46. #    tag variables to remember this information.
  47.     If "{info}" =~ /[∂']*≈,([¬ ∂']+)®1∂+[∂']*≈    Task: (≈)®2[ ]«5»Comment: (≈)®3/
  48.             Set revision "{®1}"
  49.             Set task "{®2}"
  50.             Set comment "Renamed from "{oldName}".  {®3}"
  51.     End
  52.  
  53. #    Orphan the file from its project.    
  54.     OrphanFiles "{oldName}"
  55.  
  56. #    Rename the file to the specified new name.
  57.     Rename "{oldName}" "{newName}"
  58.     
  59. #    Check in the newly named file as a new file.  The new file will have the same revision number as 
  60. #    the most recent revision of the old name, and will have the same comment and task fields.
  61.     CheckIn -new "{newName},{revision}" -cs "{comment}" -t "{task}"
  62.     
  63. #    Cancel the check out of the old name.  Note: This command will produce an Alert since the old name
  64. #    is no longer in the Projector database.
  65.     CheckOut -cancel "{oldName}" -y
  66.     
  67. #    Delete all revisions of the old name.
  68.     DeleteRevisions -file "{oldName}" -y
  69.